from django.db import models

# Create your models here.
class user(models.Model):
    username=models.CharField(max_length=100)
    password=models.CharField(max_length=100)

class category(models.Model):
    name=models.CharField(max_length=50)
    categoryid=models.ForeignKey('self',null=True,on_delete=models.SET_NULL,related_name='book')
    create_time=models.DateTimeField(auto_now_add=True)

class Book(models.Model):
    name=models.CharField(max_length=100)
    bookid=models.CharField(max_length=100,unique=True)
    categorybook=models.ForeignKey(category,on_delete=models.CASCADE,related_name='book1')
    price=models.DecimalField(max_digits=10,decimal_places=2)
    num=models.IntegerField()

class borrow(models.Model):
    bookname=models.ForeignKey(Book,on_delete=models.CASCADE,related_name='book2')
    number=models.IntegerField()
    peopel=models.CharField(max_length=100)
    create_time=models.DateTimeField(auto_now_add=True)
    gh_time=models.DateTimeField()
    sj_time=models.DateTimeField(null=True)

